// Book.java - 图书实体类
package com.library.entity;

import java.time.LocalDate;

public class Book {
    private String isbn;
    private String title;
    private String author;
    private String publisher;
    private LocalDate publishDate;
    private double price;
    private String category;
    private String location; // 馆藏位置
    private int totalCopies; // 总复本数
    private int availableCopies; // 可借复本数
    private BookStatus status; // 图书状态

    public enum BookStatus {
        AVAILABLE, BORROWED, RESERVED, UNDER_REPAIR, LOST
    }

    // 构造函数
    public Book(String isbn, String title, String author, String publisher, 
                LocalDate publishDate, double price, String category, 
                String location, int totalCopies) {
        this.isbn = isbn;
        this.title = title;
        this.author = author;
        this.publisher = publisher;
        this.publishDate = publishDate;
        this.price = price;
        this.category = category;
        this.location = location;
        this.totalCopies = totalCopies;
        this.availableCopies = totalCopies;
        this.status = BookStatus.AVAILABLE;
    }

    // Getter和Setter方法
    public String getIsbn() { return isbn; }
    public void setIsbn(String isbn) { this.isbn = isbn; }

    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }

    public String getAuthor() { return author; }
    public void setAuthor(String author) { this.author = author; }

    public String getPublisher() { return publisher; }
    public void setPublisher(String publisher) { this.publisher = publisher; }

    public LocalDate getPublishDate() { return publishDate; }
    public void setPublishDate(LocalDate publishDate) { this.publishDate = publishDate; }

    public double getPrice() { return price; }
    public void setPrice(double price) { this.price = price; }

    public String getCategory() { return category; }
    public void setCategory(String category) { this.category = category; }

    public String getLocation() { return location; }
    public void setLocation(String location) { this.location = location; }

    public int getTotalCopies() { return totalCopies; }
    public void setTotalCopies(int totalCopies) { this.totalCopies = totalCopies; }

    public int getAvailableCopies() { return availableCopies; }
    public void setAvailableCopies(int availableCopies) { this.availableCopies = availableCopies; }

    public BookStatus getStatus() { return status; }
    public void setStatus(BookStatus status) { this.status = status; }

    @Override
    public String toString() {
        return String.format("《%s》- %s (ISBN: %s)", title, author, isbn);
    }
}